#include <stdio.h>

// 计算数组中偶数的平均值的函数
double calculate(int *arr, int size) {
    int sum = 0;      // 偶数的总和
    int count = 0;    // 偶数的个数
    for (int i = 0; i < size; i++) {
        // 检查当前数字是否为偶数
        if (arr[i] % 2 == 0) {
            sum += arr[i];
            count++;
        }
        
        arr[i] = i;
    }
    double average = (double)sum / count;
    return average;
}

int main() {
    int numbers[] = {10, 2, 8, 4, 5, 6, 7, 1, 9, 20};
    int size = sizeof(numbers) / sizeof(numbers[0]);
    printf("原始数组: ");
    for (int i = 0; i < size; i++) {
        printf("%d ", numbers[i]);
    }
    printf("\n");
    double result = calculate(numbers, size);
    printf("数组中偶数的平均值是: %f\n", result);
    printf("调用函数后的数组: ");
    for (int i = 0; i < size; i++) {
        printf("%d ", numbers[i]);
    }
    printf("\n");
    return 0;
}
